/**
 * Created with IntelliJ IDEA.
 * Description:
 * User: Microsoft
 * Date: 2022-12-29
 * Time: 9:21
 */

interface  IShape {
    String name = "1";
    void draw();
    default void func() {
        System.out.println("默认的");
    }
}
//interface  IShape {
//    public String name = "1";
//    public void draw();
//    default public void func() {
//        System.out.println("默认的");
//    }
//    public static void staticFunc() {
//        System.out.println("123");
//    }
//}


abstract class Animal {
    public String name;

    public Animal(String name) {
        this.name = name;
    }

}
interface IRunning {
    void run();
}
interface ISwimming {
    void swim();
}
interface IFly {
    void fly();
}
class Dog extends Animal implements IRunning{

    public Dog(String name) {
        super(name);
    }

    @Override
    public void run() {
        System.out.println(name + "正在用四条狗腿跑");
    }
}
class Fish extends Animal implements ISwimming{

    public Fish(String name) {
        super(name);
    }

    @Override
    public void swim() {
        System.out.println(name + "正在游泳");
    }
}
class Bird extends Animal implements IFly {

    public Bird(String name) {
        super(name);
    }

    @Override
    public void fly() {
        System.out.println(name + "正在飞");
    }
}
class Duck extends Animal implements IRunning,IFly,ISwimming {
    public Duck(String name) {
        super(name);
    }

    @Override
    public void run() {
        System.out.println(name + "正在用两条腿跑");
    }

    @Override
    public void swim() {
        System.out.println(name + "正在用两条腿游泳");
    }

    @Override
    public void fly() {
        System.out.println(name + "正在用翅膀飞");
    }
}
public class Test {
    public static void walk(IRunning iRunning) {
        iRunning.run();
    }
    public static void swim(ISwimming iSwimming) {
        iSwimming.swim();
    }
    public static void main(String[] args) {
        walk(new Dog("旺财"));
        walk(new Duck("唐老鸭"));
        swim(new Fish("七秒"));

    }
}

//abstract class Rect implements IShape {
//    @Override
//    public void draw() {
//        System.out.println("矩形");
//    }
//
//    @Override
//    public void func() {
//        System.out.println("重写这个方法");
//    }
//}
//class Flower implements IShape {
//    @Override
//    public void draw() {
//        System.out.println("❀");
//    }
//}
//public class Test {
//    public static void drawMap(IShape shape) {
//        shape.draw();
//    }
//    public static void main(String[] args) {
//        //IShape shape = new IShape() ;  //error
//        IShape shape = new Rect();  //向上转型
//        IShape shape2 = new Flower();  //向上转型
//        drawMap(shape);
//        drawMap(shape2);
//        IShape.staticFunc();
//    }
//}


//abstract class Shape {
//    abstract public void draw();
//}
//class Rect extends Shape {
//    @Override
//    public void draw() {
//        System.out.println("画矩形");
//    }
//}
//class Cycle extends Shape {
//    @Override
//    public void draw() {
//        System.out.println("画圆");
//    }
//}
//class Flower extends Shape {
//    @Override
//    public void draw() {
//        System.out.println("❀");
//    }
//}
//
//public class Test {
//
//    public static void drawMap(Shape shape) {
//        shape.draw();
//    }
//    public static void main(String[] args) {
//        drawMap(new Flower());
//        drawMap(new Cycle());
//        drawMap(new Rect());
//    }
//}
